/*
 * Miccsnookersim, a snooker simulation with AI
 * Copyright (C) 2009 Enno Ruijters, Frans van den Heuvel, Yannick Thimister,
 * Ali B. Ozmen, Esther Verhoef, Achim Leydecker
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import java.util.Random;
 
public class BenchmarkPlayer implements Player
{
	Random generator;
	Ball cueBall;

	public BenchmarkPlayer(Table t)
	{
		generator = new Random(42);
		for (Ball b : t.getBalls())
			if (b.getValue() == 0)
				cueBall = b;
	}
	/**
		Returns the next shot that the AI will be making
		@return Cue object with the parameters set for the next shot
	*/
	public Cue getShot()
	{
		Cue ret; 
		ret = new Cue();
		Vector force = new Vector(generator.nextInt(1000) - 500, generator.nextInt(1000) - 500, 0); 
		ret.setForce(force); //random amount of force is set
			
		Vector v = new Vector(Ball.RADIUS, 0, 0);
		ret.setPosition(Vector.add(cueBall.getPosition(), v.rotate_(generator.nextDouble() * Math.PI / 2)));//Rotate the Cueshot randomly around the ball 
		return ret;
	}
	
	public void replaceCueBall(Table t, Ball cueBall)
	{
		cueBall.setPosition(new Vector(285, 100, 0)); //default starting postion
		t.replaceBall(cueBall);
	}

	/**
		Returns the name of the AI
		@return a String object with the name
	*/
	public String getName()
	{
		return "Benchmark";
	}

	public void terminate()
	{
		assert(false);
	}

	public void setTable(Table t)
	{
		throw new IllegalStateException();
	}
}
